from collections.abc import Mapping,MutableMapping

a = {}
print(isinstance(a, Mapping))
print(isinstance(a, MutableMapping))


# fromkeys 将可迭代对象构造为字典
lst = ["jack","rose"]
d = dict.fromkeys(lst, 100)
print(d)
#d["tom"]
print(d.get("tom", 55))

print(d.setdefault("jack", 8))

# update
d.update({"micel": 44})
d.update(fox=66)    #关键字参数更新, fox 会作为Key值
d.update([("bob",55),("jack",99)])
print(d)


class MyDict(dict):
    def __setitem__(self, key, value):
        super().__setitem__(key,value)



d = MyDict(name="caoyx")
print(d)


from collections import UserDict,defaultdict